home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nfpat7.zip / MENUTO.PRG < prev    next >
Text File  |  1993-03-02  |  21KB  |  613 lines

  1. /*
  2.  * File......: MENUTO.PRG
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   02 Mar 1993 01:03:20  $
  5.  * Revision..: $Revision:   1.7  $
  6.  * Log file..: $Logfile:   C:/nanfor/src/menuto.prv  $
  7.  * 
  8.  * This is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   C:/nanfor/src/menuto.prv  $
  15.  * 
  16.  *    Rev 1.7   02 Mar 1993 01:03:20   GLENN
  17.  * When you have SET MESSAGE x CENTER set and you do a
  18.  * 
  19.  *     @ x,y PROMPT "XXX" MESSAGE "mmmm"
  20.  * 
  21.  * the message is centered based upon the length of the prompt rather than
  22.  * the message. Gary F. Alderson 76666,357 found and fixed the bug.
  23.  * 
  24.  *    Rev 1.6   12 Jan 1993 08:57:08   GLENN
  25.  * Ted fixed a bug in which an array bounds error could occur if you
  26.  * used nested submenus.
  27.  * 
  28.  *    Rev 1.5   16 Oct 1992 00:20:28   GLENN
  29.  * Cleaned up documentation header.
  30.  * 
  31.  *    Rev 1.4   16 Oct 1992 00:08:44   GLENN
  32.  * Just making sure we had Ted's latest revision.
  33.  * 
  34.  *    Rev 1.3   13 Oct 1992 20:45:46   GLENN
  35.  * Complete rewrite by Ted Means, dumping assembler version for a
  36.  * Clipper version.
  37.  * 
  38.  *    Rev 1.2   15 Aug 1991 23:03:54   GLENN
  39.  * Forest Belt proofread/edited/cleaned up doc
  40.  * 
  41.  *    Rev 1.1   14 Jun 1991 19:52:16   GLENN
  42.  * Minor edit to file header
  43.  * 
  44.  *    Rev 1.0   01 Apr 1991 01:01:42   GLENN
  45.  * Nanforum Toolkit
  46.  *
  47.  */
  48.  
  49. /*  $DOC$
  50.  *  $FUNCNAME$
  51.  *     FT_Prompt()
  52.  *  $CATEGORY$
  53.  *     Menus/Prompts
  54.  *  $ONELINER$
  55.  *     Define a menu item for use with FT_MenuTo()
  56.  *  $SYNTAX$
  57.  *     #include "FTMENUTO.CH"
  58.  *
  59.  *     @ <nRow>, <nCol> PROMPT <cPrompt>                     ;
  60.  *                      [COLOR <cColor>]                     ;
  61.  *                      [MESSAGE <cMessage>]                 ;
  62.  *                      [MSGROW <nMsgRow>]                   ;
  63.  *                      [MSGCOL <nMsgCol>]                   ;
  64.  *                      [MSGCOLOR <cMsgColor>]               ;
  65.  *                      [TRIGGER <nTrigger>]                 ;
  66.  *                      [TRIGGERCOLOR <cTriggerColor>]       ;
  67.  *                      [HOME <nHome>]                       ;
  68.  *                      [END <nEnd>]                         ;
  69.  *                      [UP <nUp>]                           ;
  70.  *                      [DOWN <nDown>]                       ;
  71.  *                      [LEFT <nLeft>]                       ;
  72.  *                      [RIGHT <nRight>]                     ;
  73.  *                      [EXECUTE <bExec>]                    ;
  74.  *
  75.  *  $ARGUMENTS$
  76.  *     <nRow> is the row at which the prompt is to appear.
  77.  *
  78.  *     <nCol> is the column at which the prompt will appear.
  79.  *
  80.  *     <cPrompt> is the menu item string.
  81.  *
  82.  *     <cColor> is optional and is the color attribute of the prompt.  Note
  83.  *     that two colors are required; one for the standard setting and one
  84.  *     for the enhanced setting (i.e. the light bar color).  See the example
  85.  *     below if this isn't clear.  If <cColor> is not specified then the
  86.  *     current SetColor() value is used by default.
  87.  *
  88.  *     <cMessage> is optional and is the message associated with the
  89.  *     prompt. If not specified, then no message will be displayed.
  90.  *
  91.  *     <nMsgRow> is optional and is the row at which the message, if any,
  92.  *     will appear.  If not specified, the default is the current setting
  93.  *     of the SET MESSAGE TO command.
  94.  *
  95.  *     <nMsgCol> is optional and is the column at which the message, if
  96.  *     any, will appear.  If not specified, the default is either zero or
  97.  *     centered, depending on the current setting of the CENTER option of
  98.  *     the SET MESSAGE TO command.
  99.  *
  100.  *     <cMsgColor> is optional and is the color attribute of the message.
  101.  *     If not specified, the default is the same as the prompt color.
  102.  *
  103.  *     <nTrigger> is optional and is the position within the prompt string
  104.  *     where the trigger character is located.  If not specified, the
  105.  *     default is one.
  106.  *
  107.  *     <cTriggerColor> is optional and is the color attribute of the trigger
  108.  *     character.  Note that two colors are required; one for the standard
  109.  *     setting and one for the enhanced setting (i.e. the light bar color).
  110.  *     See the example below if this isn't clear.  If <cTriggerColor> is not
  111.  *     specified then the default is the same color as the rest of the
  112.  *     prompt.
  113.  *
  114.  *     <nHome> is optional and specifies which prompt becomes active
  115.  *     when the home key is pressed.  If not specified, the default is
  116.  *     the first prompt.
  117.  *
  118.  *     <nEnd> is optional and specifies which prompt becomes active
  119.  *     when the end key is pressed.  If not specified, the default is
  120.  *     the last prompt.
  121.  *
  122.  *     <nUp> is optional and specifies which prompt becomes active
  123.  *     when the up arrow key is pressed.  If not specified, the
  124.  *     default is the previous prompt.  The current setting of SET
  125.  *     WRAP TO is obeyed.
  126.  *
  127.  *     <nDown> is optional and specifies which prompt becomes
  128.  *     active when the down arrow key is pressed.  If not
  129.  *     specified, the default is the next prompt.  The current
  130.  *     setting of SET WRAP TO is obeyed.
  131.  *
  132.  *     <nRight> is optional and specifies which prompt becomes
  133.  *     active when the right arrow key is pressed.  If not
  134.  *     specified, the default is the next prompt.  The current
  135.  *     setting of SET WRAP TO is obeyed.
  136.  *
  137.  *     <nLeft> is optional and specifies which prompt becomes
  138.  *     active when the left arrow is pressed.  If not specified,
  139.  *     the default is the previous prompt.  The current setting of
  140.  *     SET WRAP TO is obeyed.
  141.  *
  142.  *     <bExec> is optional and is a code block to evaluate whenever
  143.  *     the menu item to which it belongs is selected.
  144.  *  $DESCRIPTION$
  145.  *     Clipper's @...PROMPT and MENU TO commands are fine as far as
  146.  *     they go.  But many times you need more flexibility.  As
  147.  *     you'll no doubt notice if you read the argument list, this
  148.  *     function is almost completely flexible. You can adjust
  149.  *     locations and colors for every part of the prompt and its
  150.  *     associated message.  In addition, since you can control the
  151.  *     effect of the arrow keys, you can allow both horizontal and
  152.  *     vertical movement, or even disable certain arrow keys if you
  153.  *     so desire.  Support for nested menus is also available, since
  154.  *     the prompts are stored in stack-based static arrays.
  155.  *
  156.  *     Note that this command can also be called using function-style
  157.  *     syntax.  See the entry for FT_PROMPT() for further details.
  158.  *
  159.  *     This enhanced version of @...PROMPT requires the inclusion of
  160.  *     the header file FTMENUTO.CH in any source file that uses it.
  161.  *     It is may be used in place of the standard Clipper @...PROMPT
  162.  *     command.  However, in the interests of functionality it is NOT
  163.  *     100% compatible.  No whining!  If compatibility is such a big
  164.  *     deal then use the standard Clipper commands.
  165.  *
  166.  *  $EXAMPLES$
  167.  *    #include "FTMENUTO.CH"
  168.  *
  169.  *    // Simple prompt
  170.  *    @ 1, 1 PROMPT "Menu choice #1"
  171.  *
  172.  *    // Prompt with color
  173.  *    @ 3, 1 PROMPT "Menu choice #2" COLOR "W+/R,W+/B"
  174.  *
  175.  *    // Prompt with a message
  176.  *    @ 5, 1 PROMPT "Menu choice #3" MESSAGE "Go to lunch"
  177.  *
  178.  *    // Prompt with pinpoint message control
  179.  *    @ 7, 1 PROMPT "Menu choice #4" MESSAGE "Drop Dead" ;
  180.  *                   MSGROW 22 MSGCOL 4 MSGCOLOR "GR+/N"
  181.  *
  182.  *    // Prompt with a trigger character ("#" character)
  183.  *    @11, 1 PROMPT "Menu choice #6" TRIGGER 13
  184.  *
  185.  *    // Prompt with trigger character color control
  186.  *    @13, 1 PROMPT "Menu Choice #7" TRIGGER 13 TRIGGERCOLOR "R+/BG,G+/N"
  187.  *
  188.  *    // Prompt with right and left arrow keys disabled
  189.  *    @15, 1 PROMPT "Menu Choice #8" RIGHT 8 LEFT 8
  190.  *  $INCLUDE$
  191.  *     FTMENUTO.CH
  192.  *  $SEEALSO$
  193.  *   
  194.  *  $END$
  195.  */
  196.  
  197. #include "SETCURS.CH"
  198. #include "INKEY.CH"
  199.  
  200. #xcommand if <true> then <action> => ;
  201.           if <true> ; <action> ; end
  202.  
  203. #xtranslate display( <row>, <col>, <stuff>, <color> ) => ;
  204.